﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

public partial class MyAdmin_DoiTTCN_AM : System.Web.UI.Page
{
    MembershipUser us;
    protected void Page_Load(object sender, EventArgs e)
    {
        us = Membership.GetUser(Helper.getCurrentAdminUserName(Session));

        if (!IsPostBack)
        {            
            Email.Text = us.Email;
            Question.Text = us.PasswordQuestion;
        }        
    }
    protected void btnThayDoi_Click(object sender, EventArgs e)
    {       
        us.Email = Email.Text;       
        if (!Question.Text.Equals(us.PasswordQuestion) || Answer.Text.Length > 0)
        {
            // cheat
            Answer.Text = Answer.Text.Length > 0 ? Answer.Text : "Answer";
            us.ChangePasswordQuestionAndAnswer(Session["MatKhau"].ToString(),Question.Text, Answer.Text);
        }

        Membership.UpdateUser(us);
        lblKetQua.Text = "Thay đổi thông tin thành công!";
        lblKetQua.Visible = true;
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        Response.Redirect(Helper.getCurrentPageName(Request.Url));
    }
}